<?php

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;

class DefaultDb_Repositories_LogPointsVisitedRepository extends EntityRepository
{

    public function addLog($driverId, $pointId, $action)
    {
        $em = $this->getEntityManager();
        $driver = $em->find('DefaultDb_Entities_User', $driverId);
        $point = $em->find('DefaultDb_Entities_Point', $pointId);
        $res = false;

        $logPointsVisited = new DefaultDb_Entities_LogUsersVisited();
        $logPointsVisited->setUserDriver($driver);
        $logPointsVisited->setPoint($point);
        $logPointsVisited->setCreationDate(new DateTime());
        $logPointsVisited->setAction($action);
        $em->persist($logPointsVisited);
        $em->flush();
        $res = true;
        return $res;
    }

}